home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / lib / partman / commit.d / 50format_basicfilesystems < prev    next >
Encoding:
Text File  |  2009-04-19  |  3.0 KB  |  118 lines

  1. #!/bin/sh
  2.  
  3. . /lib/partman/lib/base.sh
  4.  
  5. enable_swap
  6.  
  7. for dev in $DEVICES/*; do
  8.     [ -d "$dev" ] || continue
  9.     cd $dev
  10.     partitions=
  11.     open_dialog PARTITIONS
  12.     while { read_line num id size type fs path name; [ "$id" ]; }; do
  13.         [ "$fs" != free ] || continue
  14.         partitions="$partitions $id,$num"
  15.     done
  16.     close_dialog
  17.  
  18.     for part in $partitions; do
  19.         id=${part%,*}
  20.         num=${part#*,}
  21.         [ -f $id/method -a -f $id/format \
  22.           -a -f $id/acting_filesystem ] || continue
  23.         filesystem=$(cat $id/acting_filesystem)
  24.         case $filesystem in
  25.             ext2|fat16|fat32)
  26.             if [ -f $id/formatted ] && \
  27.                [ $id/formatted -nt $id/method ] && \
  28.                ([ ! -f $id/filesystem ] || \
  29.                 [ $id/formatted -nt $id/filesystem ]); then
  30.                 continue
  31.             fi
  32.             log "Try to create file system for $dev/$id"
  33.             if [ -f $id/mountpoint ]; then
  34.                 template=partman-basicfilesystems/progress_formatting_mountable
  35.                 db_subst $template MOUNT_POINT "$(cat $id/mountpoint)"
  36.             else
  37.                 template=partman-basicfilesystems/progress_formatting
  38.             fi
  39.             open_dialog PARTITION_INFO $id
  40.             read_line x1 x2 x3 x4 x5 device x6
  41.             close_dialog
  42.  
  43.             RET=''
  44.             db_metaget  partman/filesystem_short/"$filesystem" description || RET=''
  45.             [ "$RET" ] || RET="$filesystem"
  46.             db_subst $template TYPE "$RET"
  47.             db_subst $template PARTITION "$num"
  48.             db_subst $template DEVICE $(humandev $(cat device))
  49.             case $filesystem in
  50.                 ext2)
  51.                 if [ ! -f $id/usage ]; then
  52.                     name_progress_bar $template
  53.                     open_dialog CREATE_FILE_SYSTEM $id $filesystem
  54.                     read_line status
  55.                     close_dialog
  56.                     sync
  57.                 else
  58.                     status=failed
  59.                 fi
  60.                 if [ "$status" != OK ]; then
  61.                     db_progress START 0 3 partman/text/formatting
  62.                     db_progress INFO $template
  63.                     db_progress SET 1
  64.                     usage=''
  65.                     if [ -f $id/usage ]; then
  66.                         usage="-T $(cat $id/usage)"
  67.                     fi
  68.                     if log-output -t partman --pass-stdout \
  69.                        mkfs.ext2 $device $usage >/dev/null; then
  70.                         sync
  71.                         status=OK
  72.                     else
  73.                         status=failed
  74.                     fi
  75.                     db_progress STOP
  76.                 fi
  77.                 if [ "$status" = OK ]; then
  78.                     label=''
  79.                     if [ -f $id/label ]; then
  80.                         label=$(cat $id/label | \
  81.                             sed 's/\(................\).*/\1/g')
  82.                     fi
  83.                     if [ "$label" ]; then
  84.                         log-output -t partman --pass-stdout \
  85.                             tune2fs -L "$label" $device >/dev/null
  86.                     fi
  87.                     if [ -f $id/reserved_for_root ]; then
  88.                         log-output -t partman --pass-stdout \
  89.                             tune2fs -m $(cat $id/reserved_for_root) $device >/dev/null
  90.                     fi
  91.                 fi
  92.                 ;;
  93.                 fat16|fat32)
  94.                 name_progress_bar $template
  95.                 open_dialog CREATE_FILE_SYSTEM $id $filesystem
  96.                 read_line status
  97.                 close_dialog
  98.                 sync
  99.                 ;;
  100.             esac
  101.  
  102.             if [ "$status" != OK ]; then
  103.                 db_subst partman-basicfilesystems/create_failed TYPE "$filesystem"
  104.                 db_subst partman-basicfilesystems/create_failed PARTITION "$num"
  105.                 db_subst partman-basicfilesystems/create_failed DEVICE $(humandev $(cat device))
  106.                 db_input critical partman-basicfilesystems/create_failed || true
  107.                 db_go || true
  108.                 #disable_swap
  109.                 exit 1
  110.             fi
  111.             >$id/formatted
  112.             ;;
  113.         esac
  114.     done
  115. done
  116.  
  117. #disable_swap
  118.